/*
// Definition for a Node.
class Node {
public:
int val;
vector<Node*> children;

Node() {}

Node(int _val) {
val = _val;
}

Node(int _val, vector<Node*> _children) {
val = _val;
children = _children;
}
};
*/

class Solution {
public:
	vector<vector<int>> levelOrder(Node* root) {
		vector<vector<int>> v;
		if (root == nullptr)
		{
			return v;
		}
		queue<Node*> q;
		q.push(root);
		while (!q.empty())
		{
			int size = q.size();
			vector<int> temp;
			for (int i = 0; i<size; i++)
			{
				Node* treenode = q.front();
				q.pop();
				temp.push_back(treenode->val);
				for (int i = 0; i<treenode->children.size(); i++)
				{
					if (treenode->children[i] != nullptr)
					{
						q.push(treenode->children[i]);
					}
				}
			}
			v.push_back(temp);
		}
		return v;
	}
};
